{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 实验1 熟悉实践环境-训战平台"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 实验目的\n",
    "### 1. 开发完成一个简单的四则运算软件；\n",
    "### 2. 写出三款软件及特点；\n",
    "### 3. 掌握熟悉训战平台； \n",
    "### 4. 组件团队，确定项目。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 实验内容\n",
    "### 1. 写一个能自动生成小学四则运算题目的“软件”，要求：除了整数以外，还要支持真分数的四则运算。（用户为小学生）代码+运行截图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "题目: 69 - 5/6 = ? 答案: 409/6\n",
      "题目: 35 * 7/10 = ? 答案: 49/2\n",
      "题目: 18 / 6/7 = ? 答案: 21\n",
      "题目: 81 / 1 = ? 答案: 81\n",
      "题目: 85 * 7/10 = ? 答案: 119/2\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "from fractions import Fraction\n",
    "\n",
    "def generate_fraction():\n",
    "    # 生成一个真分数，分子范围在1到10之间，分母范围在分子到10之间\n",
    "    numerator = random.randint(1, 10)\n",
    "    denominator = random.randint(numerator, 10)\n",
    "    return Fraction(numerator, denominator)\n",
    "\n",
    "def generate_operation():\n",
    "    # 随机选择四则运算符号\n",
    "    operations = ['+', '-', '*', '/']\n",
    "    return random.choice(operations)\n",
    "\n",
    "def generate_expression():\n",
    "    a = random.randint(1, 100)\n",
    "    b = generate_fraction()\n",
    "    op = generate_operation()\n",
    "    \n",
    "    if op == '+':\n",
    "        result = a + b\n",
    "    elif op == '-':\n",
    "        result = a - b\n",
    "    elif op == '*':\n",
    "        result = a * b\n",
    "    else:\n",
    "        result = a / b\n",
    "        \n",
    "    return f\"{a} {op} {b} = ?\", result\n",
    "\n",
    "# 生成5个带注释的四则运算题目\n",
    "for _ in range(10):\n",
    "    question, answer = generate_expression()\n",
    "    print(f\"Question: {question} Answer: {answer}\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 软件有很多种：包装在盒子里的软件、基于网页的软件、企业或学校或某组织内部的软件、游戏、手机应用、操作系统、工具软件，选取三种软件，请分析它们各自的特点。 \n",
    "#### 1）\t这些软件开发者是怎么说服你（陌生人）成为他们的用户的？他们的目标都是盈利么？他们的目标都是赚取用户现金么？还是别的？\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答：我们常用的软件推广而来，听别人介绍和网友的推荐；他们的目的我觉得是拉拢我们这些，当作长期顾客，使盈利长久化，赚取用户现金只是一部分，主要是维持他们软件的信誉和可靠度。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
